using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Transforms;

partial struct BulletMoverSystem : ISystem
{
    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        foreach ((
            RefRW<LocalTransform> localTransform,
            RefRO<BulletMover> bulletMover,
            RefRW<PhysicsVelocity> physicsVelocity) 
            in SystemAPI.Query<
                RefRW<LocalTransform>,
                RefRO<BulletMover>,
                RefRW<PhysicsVelocity>>())
        {
            float3 motion = bulletMover.ValueRO.moveDir * bulletMover.ValueRO.moveSpeed;
            //UnityEngine.Debug.Log(motion); UnityEngine.Debug.Log(bulletMover.ValueRO.moveSpeed);
            physicsVelocity.ValueRW.Linear = motion;
            //localTransform.ValueRW.Rotation = quaternion.LookRotation(bulletMover.ValueRO.moveDir, math.up());
        }
    }
}
